-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block editor: rewrite selection clearer #27468
Conversation
6b3a907
to
4538409
Compare
Size Change: +29 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
bf85a9c
to
6161bfa
Compare
4b46a86
to
c34a199
Compare
function onFocus() { | ||
function onMouseDown( event ) { | ||
// Only handle clicks on the canvas, not the content. | ||
if ( event.target.closest( '.wp-block' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition could be removed eventually when the content is directly rendered into the wrapper the mousedown
event is listened for. Currently there are a few wrappers in between the selection clearer and the block for which we also need to detect clicks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this PR break the selection clearer in the widgets screen (you can't click any button on the toolbar). .wp-block
must not be enough.
Ii also wonder why you're using mousedown, focusing outside (without clicking) should also have the same behavior right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to restore the previous behavior for now to perform a patch release.
I think this kind of impactful PRs could use more reviews. |
@@ -64,7 +64,6 @@ export default function VisualEditor() { | |||
<div | |||
ref={ ref } | |||
className="editor-styles-wrapper" | |||
tabIndex="-1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know why this was here and why this was removed?
This reverts commit 6c9efd4.
Description
Currently the selection clearer works by catching focus on a wrapper. Because of this focusable element, it's trickier to remove the wrapper and share it with the click redirect wrapper. Additionally, it also tricky to remove in the context of an iframe where the
body
element cannot be truly focusable (because of how the browser handler focus loss, returning focus to thebody
element in that case, without firing any focus events).The selection clearer can easily be rewritten to look for clicks instead of focus. There's already a precedent of doing so in the click redirect, where we redirect focus to the last block if the user clicks at the bottom of the editor. The clearer is basically the same thing, detecting clicks around the content to clear the block selection.
How has this been tested?
Screenshots
Types of changes
Checklist: